Model fit

Column

Assumption checks

Column

Indices of model fit

Metric Value
ELPD -91.30
ELPD_SE 4.44
LOOIC 182.59
LOOIC_SE 8.89
WAIC 182.40
R2 0.59
R2 (adj.) 0.54
RMSE 3.74
Sigma 3.93

For interpretation of performance metrics, please refer to this documentation.

Parameter estimates

Column

Plot

Column

Tabular summary

Parameter Median 95% CI pd Rhat ESS Prior
(Intercept) 30.12 (26.86, 33.35) 100% 1.002 3249.00 Normal (20.09 +- 15.07)
hp -0.07 (-0.09, -0.05) 100% 1.002 3110.00 Normal (0.00 +- 0.22)

To find out more about table summary options, please refer to this documentation.

Predicted Values

Column

Plot

Column

Tabular summary

Error: pandoc document conversion failed with error 1

Text reports

Column

Textual summary

We fitted a Bayesian linear model (estimated using MCMC sampling with 4 chains of 2000 iterations and a warmup of 1000) to predict mpg with hp (formula: mpg ~ hp). Priors over parameters were set as normal (mean = 0.00, SD = 0.22) distributions. The model’s explanatory power is substantial (R2 = 0.59, 95% CI (0.38, 0.75), adj. R2 = 0.54). The model’s intercept, corresponding to hp = 0, is at 30.12 (95% CI (26.86, 33.35)). Within this model:

  • The effect of hp (Median = -0.07, 95% CI (-0.09, -0.05)) has a 100.00% probability of being negative (< 0), 0.00% of being significant (< -0.30), and 0.00% of being large (< -1.81). The estimation successfully converged (Rhat = 1.002) and the indices are reliable (ESS = 3110)

Following the Sequential Effect eXistence and sIgnificance Testing (SEXIT) framework, we report the median of the posterior distribution and its 95% CI (Highest Density Interval), along the probability of direction (pd), the probability of significance and the probability of being large. The thresholds beyond which the effect is considered as significant (i.e., non-negligible) and large are |0.30| and |1.81| (corresponding respectively to 0.05 and 0.30 of the outcome’s SD). Convergence and stability of the Bayesian sampling has been assessed using R-hat, which should be below 1.01 (Vehtari et al., 2019), and Effective Sample Size (ESS), which should be greater than 1000 (Burkner, 2017). The model’s explanatory power is substantial (R2 = 0.59, 95% CI (0.38, 0.75), adj. R2 = 0.54)

Column

Model information

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : Argumente implizieren unterschiedliche Anzahl Zeilen: 1, 0
List of 48
 $ is_binomial     : logi FALSE
 $ is_bernoulli    : logi FALSE
 $ is_count        : logi FALSE
 $ is_poisson      : logi FALSE
 $ is_negbin       : logi FALSE
 $ is_beta         : logi FALSE
 $ is_betabinomial : logi FALSE
 $ is_orderedbeta  : logi FALSE
 $ is_dirichlet    : logi FALSE
 $ is_exponential  : logi FALSE
 $ is_logit        : logi FALSE
 $ is_probit       : logi FALSE
 $ is_censored     : logi FALSE
 $ is_truncated    : logi FALSE
 $ is_survival     : logi FALSE
 $ is_linear       : logi TRUE
 $ is_tweedie      : logi FALSE
 $ is_zeroinf      : logi FALSE
 $ is_zero_inflated: logi FALSE
 $ is_dispersion   : logi FALSE
 $ is_hurdle       : logi FALSE
 $ is_ordinal      : logi FALSE
 $ is_cumulative   : logi FALSE
 $ is_multinomial  : logi FALSE
 $ is_categorical  : logi FALSE
 $ is_mixed        : logi FALSE
 $ is_multivariate : logi FALSE
 $ is_trial        : logi FALSE
 $ is_bayesian     : logi TRUE
 $ is_gam          : logi FALSE
 $ is_anova        : logi FALSE
 $ is_timeseries   : logi FALSE
 $ is_ttest        : logi FALSE
 $ is_correlation  : logi FALSE
 $ is_onewaytest   : logi FALSE
 $ is_chi2test     : logi FALSE
 $ is_ranktest     : logi FALSE
 $ is_levenetest   : logi FALSE
 $ is_variancetest : logi FALSE
 $ is_xtab         : logi FALSE
 $ is_proptest     : logi FALSE
 $ is_binomtest    : logi FALSE
 $ is_ftest        : logi FALSE
 $ is_meta         : logi FALSE
 $ link_function   : chr "identity"
 $ family          : chr "gaussian"
 $ n_obs           : int 32
 $ n_grouplevels   : NULL
Error in DT::datatable(model_info_data): 'data' must be 2-dimensional (e.g. data frame or matrix)
---
title: "Regression model summary from `{easystats}`"
output: 
  flexdashboard::flex_dashboard:
    theme:
      version: 4
      # bg: "#101010"
      # fg: "#FDF7F7" 
      primary: "#0054AD"
      base_font:
        google: Prompt
      code_font:
        google: JetBrains Mono
params:
  model: model
  check_model_args: check_model_args
  parameters_args: parameters_args
  performance_args: performance_args
---

```{r setup, include=FALSE}
library(flexdashboard)
library(easystats)

# Since not all regression model are supported across all packages, make the
# dashboard chunks more fault-tolerant. E.g. a model might be supported in
# `{parameters}`, but not in `{report}`.
#
# For this reason, `error = TRUE`
knitr::opts_chunk$set(
  error = TRUE,
  out.width = "100%"
)

# helper function for printing `{report}` outputs
bracket_to_parantheses <- function(text) {
  gsub("]", ")", gsub("[", "(", text, fixed = TRUE), fixed = TRUE)
}
```

```{r easydashboard-1}
# Get user-specified model data
model <- params$model

# Is it supported by `{easystats}`? Skip evaluation of the following chunks if not.
is_supported <- insight::is_model_supported(model)

if (!is_supported) {
  unsupported_message <- sprintf(
    "Unfortunately, objects of class `%s` are not yet supported in {easystats}.\n
    For a list of supported models, see `insight::supported_models()`.",
    class(model)[1]
  )
}
```


Model fit 
=====================================  

Column {data-width=700}
-----------------------------------------------------------------------

### Assumption checks

```{r check-model, eval=is_supported, fig.height=10, fig.width=10}
check_model_args <- c(list(model), params$check_model_args)
# add verbose, if not done yet
if (is.null(check_model_args$verbose)) check_model_args$verbose <- FALSE
tryCatch(
  {
    do.call(performance::check_model, check_model_args)
  },
  error = function(e) {
    cat(insight::format_message(
      "\nSomething did not work as expected. Please file an issue at {.url https://github.com/easystats/easystats/issues/} and post the following output:",
      paste0("\n`", e$message, "`")
    ))
  }
)
```

```{r easydashboard-2, eval=!is_supported}
cat(unsupported_message)
```

Column {data-width=300}
-----------------------------------------------------------------------

### Indices of model fit

```{r easydashboard-3, eval=is_supported}
# {performance}
performance_args <- c(list(model), params$performance_args)
# add verbose, if not done yet
if (is.null(performance_args$verbose)) performance_args$verbose <- FALSE
table_performance <- do.call(performance::performance, performance_args)
print_md(table_performance, layout = "vertical", caption = NULL)
```


```{r easydashboard-4, eval=!is_supported}
cat(unsupported_message)
```

For interpretation of performance metrics, please refer to <a href="https://easystats.github.io/performance/reference/model_performance.html" target="_blank">this documentation</a>.

Parameter estimates
=====================================  

Column {data-width=550}
-----------------------------------------------------------------------

### Plot

```{r dot-whisker, eval=is_supported}
# `{parameters}`
parameters_args <- c(list(model), params$parameters_args)
# add verbose, if not done yet
if (is.null(parameters_args$verbose)) parameters_args$verbose <- FALSE
table_parameters <- do.call(parameters::parameters, parameters_args)

plot(table_parameters)
```


```{r easydashboard-5, eval=!is_supported}
cat(unsupported_message)
```

Column {data-width=450}
-----------------------------------------------------------------------

### Tabular summary

```{r easydashboard-6, eval=is_supported}
print_md(table_parameters, caption = NULL)
```


```{r easydashboard-7, eval=!is_supported}
cat(unsupported_message)
```

To find out more about table summary options, please refer to <a href="https://easystats.github.io/parameters/reference/model_parameters.html" target="_blank">this documentation</a>.


Predicted Values
=====================================  

Column {data-width=600}
-----------------------------------------------------------------------

### Plot

```{r expected-values, eval=is_supported, fig.height=10, fig.width=10}
# {modelbased}
int_terms <- find_interactions(model, component = "conditional", flatten = TRUE)
con_terms <- find_variables(model)$conditional

if (is.null(int_terms)) {
  model_terms <- con_terms
} else {
  model_terms <- clean_names(int_terms)
  int_terms <- unique(unlist(strsplit(clean_names(int_terms), ":", fixed = TRUE)))
  model_terms <- c(model_terms, setdiff(con_terms, int_terms))
}

# check some exceptions here: logistic regression models with factor response
# usually require the response to be included in the model, else `get_modelmatrix()`
# fails, which is required to compute SE/CI for `get_predicted()`
response <- find_response(model)
minfo <- model_info(model)
model_data <- get_data(model)
include_response <- minfo$is_binomial && minfo$is_logit && is.factor(model_data[[response]])

text_modelbased <- tryCatch(
  {
    lapply(unique(model_terms), function(i) {
      grid <- get_datagrid(
        model,
        at = i,
        range = "grid",
        preserve_range = FALSE,
        verbose = FALSE,
        include_response = include_response
      )
      estimate_expectation(model, data = grid, verbose = FALSE)
    })
  },
  error = function(e) {
    cat(insight::format_message(
      "\nSomething did not work as expected. Please file an issue at {.url https://github.com/easystats/easystats/issues/} and post the following output:",
      paste0("\n`", e$message, "`")
    ))
    NULL
  }
)

if (!is.null(text_modelbased)) {
  ggplot2::theme_set(theme_modern())
  # all_plots <- lapply(text_modelbased, function(i) {
  #   out <- do.call(visualisation_recipe, c(list(i), modelbased_args))
  #   plot(out) + ggplot2::ggtitle("")
  # })
  all_plots <- lapply(text_modelbased, function(i) {
    out <- visualisation_recipe(i, show_data = "none")
    plot(out) + ggplot2::ggtitle("")
  })

  see::plots(all_plots, n_columns = round(sqrt(length(text_modelbased))))
}
```


```{r easydashboard-8, eval=!is_supported}
cat(unsupported_message)
```

Column {data-width=400}
-----------------------------------------------------------------------

### Tabular summary

```{r easydashboard-9, eval=is_supported, results="asis"}
if (!is.null(text_modelbased)) {
  for (i in text_modelbased) {
    tmp <- print_md(i)
    tmp <- gsub("Variable predicted", "\nVariable predicted", tmp, fixed = TRUE)
    tmp <- gsub("Predictors modulated", "\nPredictors modulated", tmp, fixed = TRUE)
    tmp <- gsub("Predictors controlled", "\nPredictors controlled", tmp, fixed = TRUE)
    print(tmp)
  }
}
```


```{r easydashboard-10, eval=!is_supported}
cat(unsupported_message)
```


Text reports
=====================================    

Column {data-width=500}
-----------------------------------------------------------------------

### Textual summary

```{r easydashboard-11, eval=is_supported, results='asis', collapse=TRUE}
# {report}
text_report <- tryCatch(
  {
    report(model, verbose = FALSE)
  },
  error = function(e) {
    cat(insight::format_message(
      "\nSomething did not work as expected. Please file an issue at {.url https://github.com/easystats/easystats/issues/} and post the following output:",
      paste0("\n`", e$message, "`")
    ))
    NULL
  }
)


text_report_performance <- tryCatch(
  {
    report_performance(model, verbose = FALSE)
  },
  error = function(e) {
    cat(insight::format_message(
      "\nSomething did not work as expected. Please file an issue at {.url https://github.com/easystats/easystats/issues/} and post the following output:",
      paste0("\n`", e$message, "`")
    ))
    NULL
  }
)

if (!is.null(text_report)) {
  cat(bracket_to_parantheses(text_report))
  cat("\n")
}

if (!is.null(text_report_performance)) {
  cat(bracket_to_parantheses(text_report_performance))
}
```


```{r easydashboard-12, eval=!is_supported}
cat(unsupported_message)
```

Column {data-width=500}
-----------------------------------------------------------------------

### Model information

```{r easydashboard-13, eval=is_supported}
model_info_data <- insight::model_info(model, verbose = FALSE)
model_info_data <- datawizard::data_to_long(as.data.frame(model_info_data))

DT::datatable(model_info_data)
```

```{r easydashboard-14, eval=!is_supported}
cat(unsupported_message)
```